<template>
	<u-index-list :scrollTop="scrollTop" :index-list="indexList">
		<view v-for="(item, index) in list" :key="index">
			<u-index-anchor :index="item.letter" />
			<view class="list-cell u-border-bottom" v-for="(item1, index) in item.data" :key="index">
				<view @click="bindClick({id:item1.id, express_code:item1.code100, name:item1.name})">{{item1.name}}</view>
			</view>
		</view>
	</u-index-list>
</template>

<script>
	import {getExpressGroutList} from '@/api/store';
	export default {
		data() {
			return {
				scrollTop: 0,
				indexList: [],
				list: []
			}
		},
		onLoad() {
			this.getExpressListFun();
		},
		methods: {
			async getExpressListFun() {
				const {
					code,
					data
				} = await getExpressGroutList({})
				if (code == 1) {
					this.list = data;
					this.indexList = data.map(val => {
						return val.letter;
					});
				}
			},
			bindClick(data) {
				uni.$emit('chooseexpress', data)
				uni.navigateBack()
				// console.log('点击5555555item，返回数据' + JSON.stringify(e))
			},
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		
	}
</script>

<style lang="scss" scoped>
	.list-cell {
		display: flex;
		box-sizing: border-box;
		width: 100%;
		padding: 10px 24rpx;
		overflow: hidden;
		color: $u-content-color;
		font-size: 14px;
		line-height: 24px;
		background-color: #fff;
	}
</style>
